package site.xuxingcan.autoclick;

import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Timer;
import java.util.TimerTask;

public class MainActivity extends AppCompatActivity {
    public static ArrayList<APPInfo> AppList = new ArrayList<>();

    public static class APPInfo {
        public String packageName;
        public String ActivityName;

        public APPInfo(String packageName, String activityName) {
            this.packageName = packageName;
            ActivityName = activityName;
        }
    }

    static {
        //mCurrentFocus=Window{4a989940 u0 com.nebulaline.nebulaline/com.nebulaline.nebulaline.MainActivity}
        AppList.add(new APPInfo("com.nebulaline.nebulaline", "com.nebulaline.nebulaline.MainActivity"));

        //mCurrentFocus=Window{4aa4dd30 u0 com.basketballabroad.basketballabroad/com.basketballabroad.basketballabroad.MainActivity}
        AppList.add(new APPInfo("com.basketballabroad.basketballabroad", "com.basketballabroad.basketballabroad.MainActivity"));

        //mCurrentFocus=Window{4aa6084c u0 com.hothollywoodgossip.hothollywood/com.hothollywoodgossip.hothollywood.MainActivity}
        AppList.add(new APPInfo("com.hothollywoodgossip.hothollywood", "com.hothollywoodgossip.hothollywood.MainActivity"));

        // mCurrentFocus=Window{4a9a8a40 u0 com.gossipexpress.gossipexpress/com.gossipexpress.gossipexpress.MainActivity}
        AppList.add(new APPInfo("com.gossipexpress.gossipexpress", "com.gossipexpress.gossipexpress.MainActivity"));

        // mCurrentFocus=Window{4a94d69c u0 com.kbabasketball.k_basketball/com.kbabasketball.k_basketball.MainActivity}
        AppList.add(new APPInfo("com.kbabasketball.k_basketball", "com.kbabasketball.k_basketball.MainActivity"));

        //mCurrentFocus=Window{4aac7a10 u0 com.grainmag.grainmag/com.grainmag.grainmag.MainActivity}
        AppList.add(new APPInfo("com.grainmag.grainmag", "com.grainmag.grainmag.MainActivity"));

        //mCurrentFocus=Window{4aa5af90 u0 com.thefootballsports.thefootballsports/com.thefootballsports.thefootballsports.MainActivity}
        AppList.add(new APPInfo("com.thefootballsports.thefootballsports", "com.thefootballsports.thefootballsports.MainActivity"));

        //mCurrentFocus=Window{4a922cfc u0 com.peemedia.peemedia/com.peemedia.peemedia.MainActivity}
        AppList.add(new APPInfo("com.peemedia.peemedia", "com.peemedia.peemedia.MainActivity"));

        Collections.shuffle(AppList);
    }

    private Context mContext;
    private int times = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mContext = this;
        findViewById(R.id.start).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startService(new Intent(MainActivity.this, ClickService.class));
            }
        });
    }

    public static void start() {
        Log.i("xuxingcan", RootShell.getTopActivity());
    }
}
